package com.learn.step04_nullsafety

/**
 *
 *
 * @author: hbliy
 * @date: 2025/7/9 17:58
 */
fun main(args: Array<String>) {
    var signatureDrink = "Buttered Ale"
    // 编译失败
//    signatureDrink = null

    // 控制台输入
    var beverage = readLine();
    println(beverage)
    val newBeverage = beverage?.capitalize()
    println(newBeverage)

    beverage = null
    println(beverage)


    var name: String? = "zhangsan";
    name = null;


    name = readLine()?.let {
        if (it.isNotBlank()) {
            it.capitalize()
        } else {
            "Empty"
        }
    }
    println("使用 let 处理：$name")

    println("!!. Enter name:")
    name = readLine()!!.capitalize();
    println("!!. = $name")

    println("Enter name:")
    name = readLine()
    if (name != null) {
        name = name.capitalize()
    }
    println("if check: $name")



}
